home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / as / sprite / messages.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-28  |  3.5 KB  |  156 lines

  1. /* messages.c - error reporter -
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GAS, the GNU Assembler.
  5.  
  6. GAS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GAS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GAS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include <stdio.h>        /* define stderr */
  21. #include "as.h"
  22. #ifndef NO_VARARGS
  23. #include <varargs.h>
  24. #endif
  25.  
  26. /*
  27.         ERRORS
  28.  
  29.     We print the error message 1st, beginning in column 1.
  30.     All ancillary info starts in column 2 on lines after the
  31.     key error text.
  32.     We try to print a location in logical and physical file
  33.     just after the main error text.
  34.     Caller then prints any appendices after that, begining all
  35.     lines with at least 1 space.
  36.  
  37.     Optionally, we may die.
  38.     There is no need for a trailing '\n' in your error text format
  39.     because we supply one.
  40.  
  41. as_warn(fmt,args)  Like fprintf(stderr,fmt,args) but also call errwhere().
  42.  
  43. as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
  44.  
  45. */
  46.  
  47. extern int had_warnings;
  48.  
  49. /*
  50.  *            a s _ w a r n ( )
  51.  *
  52.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
  53.  * in input file(s).
  54.  * Please only use this for when we have some recovery action.
  55.  * Please explain in string (which may have '\n's) what recovery was done.
  56.  */
  57.  
  58. #ifdef NO_VARARGS
  59. /*VARARGS1*/
  60. as_warn(Format,args)
  61. char *Format;
  62. {
  63.   if ( ! flagseen ['W'])    /* -W supresses warning messages. */
  64.     {
  65.       had_warnings = 1;
  66.       as_where();
  67.       _doprnt (Format, &args, stderr);
  68.       (void)putc ('\n', stderr);
  69.       /* as_where(); */
  70.     }
  71. }
  72. #else
  73. void
  74. as_warn(Format,va_alist)
  75. char *Format;
  76. va_dcl
  77. {
  78.   va_list args;
  79.  
  80.   if( ! flagseen['W'])
  81.     {
  82.       had_warnings = 1;
  83.       as_where();
  84.       va_start(args);
  85.       vfprintf(stderr, Format, args);
  86.       va_end(args);
  87.       (void) putc('\n', stderr);
  88.     }
  89. }
  90. #endif
  91. #ifdef DONTDEF
  92. void
  93. as_warn(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  94. char *format;
  95. {
  96.     if(!flagseen['W']) {
  97.             had_warnings = 1;
  98.         as_where();
  99.         fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  100.         (void)putc('\n',stderr);
  101.     }
  102. }
  103. #endif
  104. /*
  105.  *            a s _ f a t a l ( )
  106.  *
  107.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal
  108.  * message, and locate stdsource in input file(s).
  109.  * Please only use this for when we DON'T have some recovery action.
  110.  * It exit()s with a warning status.
  111.  */
  112.  
  113. #ifdef NO_VARARGS
  114. /*VARARGS1*/
  115. as_fatal (Format, args)
  116. char *Format;
  117. {
  118.   as_where();
  119.   fprintf(stderr,"FATAL:");
  120.   _doprnt (Format, &args, stderr);
  121.   (void)putc ('\n', stderr);
  122.   /* as_where(); */
  123.   exit(42);            /* What is a good exit status? */
  124. }
  125. #else
  126. void
  127. as_fatal(Format,va_alist)
  128. char *Format;
  129. va_dcl
  130. {
  131.   va_list args;
  132.  
  133.   as_where();
  134.   va_start(args);
  135.   fprintf (stderr, "FATAL:");
  136.   vfprintf(stderr, Format, args);
  137.   (void) putc('\n', stderr);
  138.   va_end(args);
  139.   exit(42);
  140. }
  141. #endif
  142. #ifdef DONTDEF
  143. void
  144. as_fatal(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  145. char *Format;
  146. {
  147.   as_where();
  148.   fprintf (stderr, "FATAL:");
  149.   fprintf(stderr, Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  150.   (void) putc('\n', stderr);
  151.   exit(42);
  152. }
  153. #endif
  154.  
  155. /* end: messages.c */
  156.